package com.jvxb.manage.livable.controller;

import com.jvxb.common.utils.CommonUtil;
import com.jvxb.common.web.RespMsg;
import com.jvxb.manage.livable.service.dbMonitor.DbMonitorService;
import com.jvxb.manage.livable.vo.MonitorIndexParam;
import com.jvxb.manage.livable.vo.MonitorParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author jvxb
 * @since 2022-02-14
 */
@RestController
@RequestMapping("/cluster/monitor")
public class ClusterMonitorController {

    @Autowired
    DbMonitorService dbMonitorService;

    @GetMapping("/metricIndex")
    public RespMsg metricIndex(MonitorIndexParam monitorIndexParam) {
        List metricIndex = dbMonitorService.getMetricIndex(monitorIndexParam);
        return RespMsg.ok(metricIndex);
    }

    @GetMapping("/metricData")
    public RespMsg metricData(MonitorParam monitorParam) {
        List metricData = dbMonitorService.getMetricIndexData(monitorParam);
        String unit = dbMonitorService.getMetricUnitByMetricName(monitorParam.getMoniObjType(), monitorParam.getMetricName());
        return RespMsg.ok(metricData).message(unit);
    }

}
